$(function($) {

//getToken();
//ajaxApi('#comic_add','api/test.php');

//右侧浮动效果
$("#right").floatdiv('middletop');
});

//global
var host      = 'http://www.super-bento.com/xiaoxinji/';
//var token_api = host+'api/token.php';

function ajaxApi(formID,url,method){
	var method = arguments[2] ? arguments[2] : 'GET';
	var token  = $("#token input[name='token']").val();
	var postData = $('#'+formID).serialize();
	console.log('token is:'+token);

	$.ajax({
	   type: method,
	   url:  host+url,
	   data: postData,
	   beforeSend: function(xhr){
       		xhr.setRequestHeader('USERTOKEN', token);
       },
	   success: function(msg){
	   	 if(msg.state == '1') r = "<font color='green'>"+JSON.stringify(msg)+"</font>";
	   	 if(msg.state == '0') r = "<font color='red'>"+JSON.stringify(msg)+"</font>";
	     $('#Result').html(r);
	   }
	});

}


